package edu.cuit.canary;

public class DataTypeDemo {
    public static void main(String[] args) {
        byte num1 = 120;
        //短整型,占用两个字节存储空间
        short num2 = 10000;
        //整型int:占用4个字节
        int num3 = 100;
        //长整型long: 占用8个字节
        long num4 = 100;
        //给long赋值时，因为整数默认是int类型，要转换为long类型的值，后面加上l或L
        long num5 = 21_474_836_470L;
        System.out.println(num5);

        //同一个整数可以使用不同的进制表示
        int num6 = 0b01111001;
        System.out.println(num6); //转换成10进制显示
        int num7 = 012345671;
        System.out.println(num7);
        int num8 = 0xABCDEF1;
        System.out.println(num8);
        //浮点型默认的类型是double，直接赋值给float类型需要加上f或者F
        float num9 = 3.14159265358979323846f;
        double num10 = 3.14159265358979323846;

        System.out.println("float:" + num9);
        System.out.println("double:" + num10);

        double result = 1.0 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1;
        System.out.println(result);
    }
}
